A pangram is a string that contains every letter of the alphabet at least once. This includes both uppercase and lowercase letters.
import string
def is_pangram(sentence):
alphabet = set(string.ascii_lowercase)
return set(sentence.lower()) >= alphabet
# Taking input for the sentence and checking if it is a pangram
def check_and_display_pangram():
sentence = input("Enter a sentence: ")
if is_pangram(sentence):
print("The sentence is a pangram.")
else:
print("The sentence is not a pangram.")
check_and_display_pangram()
Enter a sentence: The quick brown fox jumps over the lazy dog
The sentence is a pangram.
Enter a sentence: This is not a pangram
The sentence is not a pangram.
The function is_pangram(sentence)
checks whether a given sentence is a pangram or not by comparing the set of lowercase letters in the sentence with the set of all lowercase letters in the alphabet.
The function check_and_display_pangram()
takes input for the sentence, checks if it is a pangram using the aforementioned function, and displays the result.